
f = open('test.txt', 'r', encoding='utf-8')
# <class '_io.TextIOWrapper'>
print(type(f))

# 读取全部的内容
# str = f.read()
# print(str)

# 读取所有的行
# my_list = f.readlines()
# print(type(my_list))
# ['1a\n', '2b\n', '3c\n', '4d\n', '5e\n', '6f\n']
# print(my_list)

str = f.readline()
print(str, len(str))

for line in open('test.txt', 'r'):
    print(line, end='')

# 文件的关闭
f.close()

